@extends("layouts.common")
@section("content")
    <style>
        .panel .panel-heading .panel-actions {
            float: right;
            margin-right: -15px;
            height: 40px;
            font-size: 0;
            width: 30%;
            text-align: right;
        }
    </style>

    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><i class="fa fa-table"></i>我的代理</h3>
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a href="/welcome">Home</a></li>
                <li><i class="fa fa-table"></i>我的代理</li>
            </ol>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-indent red"></i><strong>搜索</strong></h2>
                </div>
                <form action="" method="get" class="form-inline">
                    <div class="panel-body">

                        <div class="form-group">
                            <label class="sr-only" for="if-password">姓名</label>
                            <input type="text" id="if-password" name="name" class="form-control" placeholder="姓名">
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="if-email">Email</label>
                            <input type="text" id="if-email" name="email" class="form-control" placeholder="邮箱">
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="if-email">Email</label>
                            <input type="text" id="if-email" name="phone" class="form-control" placeholder="手机号">
                        </div>
                    </div>
                    <div class="panel-footer">
                        <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> 搜索</button>
                        <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i> 重置</button>
                    </div>
                </form>
            </div>

        </div>
    </div>

    <div class="row">

        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-table red"></i><span class="break"></span><strong>我的代理</strong></h2>

                    <div class="panel-actions">
                        <a href="/agent/agentlist/{{Auth::user()->id}}" style=""><i class="fa  fa-table"></i>交易记录&nbsp;&nbsp;</a>
                        <a href="/agent/add"><i class="fa  fa-plus"></i>添加代理&nbsp;&nbsp;</a>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-condensed">
                        <thead>
                        <tr>
                            <th>姓名</th>
                            <th>邮箱</th>
                            <th>手机</th>
                            <th>提成</th>
                            <th>操作</th>
                            {{--<th>上级</th>--}}
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($data as $val)
                        <tr>
                            <td>{{$val->name}}</td>
                            <td>{{$val->email}}</td>
                            <td>{{$val->phone}}</td>
                            <td>{{$val->percent}}%</td>
                            <td><a href="/agent/agentlist/{{$val->id}}" data-val="{{$val->id}}">交易记录</a></td>
                            {{--<td>{{$val->pname}}</td>--}}
                        </tr>
                            @endforeach

                        </tbody>
                    </table>
                    @include("layouts.page",['paginator'=>$data])
                </div>
            </div>
        </div><!--/col-->
    </div>

    <style>
        td,th{
            text-align: center;
        }
    </style>
    <script>
        $(function () {
            var search = location.search.substring(1);
            if (search) {
                try {
                    var query = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');

                    $.each(query, function(k, v) {
                        $('[name=' + k + ']').val(v);
                    });
                } catch (e) {
                    console.log(e);
                }

            }
        });
    </script>
@endsection